<?php

    $g_hObjects = array();
    
    function ClassDestructor()
    {
	global $g_hObjects;
	
	if(count($g_hObjects))
	{
	    $g_hObjects = array_reverse($g_hObjects);
	    reset($g_hObjects);
	    
	    while (list($key, $val) = each($g_hObjects)) 
	    {
		$val->OnDestroy();
	    }
	    
	}
	
	unset($g_hObjects);
    }		
    
    register_shutdown_function("ClassDestructor");
?>